﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace SystemIO
{
    class Program
    {
        static void Main(string[] args)
        {

            for (int i = 0; i < 5; ++i)
            {
                FileStream fs = File.Create(@"E:\MyFolder\fuck off" + i + ".txt");
                String str = "hello hello hello";
                byte[] arr = GetByteFromString(str);
                fs.Write(arr, 0, arr.Length);
                fs.Close();
            }







            //FileInfo f = new FileInfo(@"E:\MyFolder\Test.txt");
            //FileStream fs = f.Create();
            //fs.Close();






        }
        // string str = "Какой-то текст бля бла бла!!!";
        // byte[] by =  GetByteFromString(str);
        public static byte[] GetByteFromString(string st)
        {
            return Encoding.UTF8.GetBytes(st);
        }
        public static String GetStringFromBytes(byte[] b)
        {
            return Encoding.ASCII.GetString(b);
        }
        public static void DispleyImageFiles()
        {
            DirectoryInfo dir = new DirectoryInfo(@"E:\TestImage");

            FileInfo[] imageFiles = dir.GetFiles("*.jpg", SearchOption.AllDirectories);
            Console.WriteLine("Found {0} *.jpg files\n",imageFiles.Length);

            foreach(FileInfo f in imageFiles)
            {
                Console.WriteLine("*************************");
                Console.WriteLine("File name: {0}",f.Name);
                Console.WriteLine("File size: {0}",f.Length);
                Console.WriteLine("Creation: {0}",f.CreationTime);
                Console.WriteLine("Attributes: {0}",f.Attributes);
                Console.WriteLine("*************************\n");
            }
        }
        public static void FunWhithDirectoryType()
        {
            //DirectoryInfo dir = new DirectoryInfo(@"E:\");
            //dir.CreateSubdirectory("MyFolder");
            //dir.CreateSubdirectory(@"MyFolder2\Data");
            string[] drives = Directory.GetLogicalDrives();
            Console.WriteLine("Here your drives:");

            foreach (string s in drives)
                Console.WriteLine("--> {0}", s);
            /////////////////////////////////////////////

            Console.WriteLine("Press Enter to delete directories");
            Console.ReadLine();
            try
            {
                Directory.Delete(@"E:\MyFolder");
                Directory.Delete(@"E:\ MyFolder2", true);
            }
            catch (IOException e)
            {
                Console.WriteLine(e.Message);
            }            
        }
        public static void DriveInfoOperatoin()
        {
                        DriveInfo[] MyDrives = DriveInfo.GetDrives();
            foreach(DriveInfo d in MyDrives)
            {
                Console.WriteLine("Name: {0}",d.Name);
                Console.WriteLine("Type: {0}", d.DriveType);

                if(d.IsReady)
                {
                    Console.WriteLine("Free space: {0}",d.TotalFreeSpace);
                    Console.WriteLine("Format: {0}",d.DriveFormat);
                    Console.WriteLine("Lable: {0}",d.VolumeLabel);
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }

    }
}
